const nodemailer = require('nodemailer');

const host = 'smtp.qq.com';
const port = 465;
const user = '529548969@qq.com';
const pass = 'togkafwvpbssbjbb';
const toList = '529548969@qq.com, 764256546@qq.com, 495073866@qq.com, destroe@163.com'; // 逗号分隔
const from = '"SSR自动发布" <529548969@qq.com>';

const transporter = nodemailer.createTransport({
  host,
  port, // SMTP 端口
  secureConnection: true, // 使用 SSL
  auth: {
    user,
    // 这里密码不是qq密码，是你设置的smtp授权码
    pass,
  },
});

async function send(subject, html) {
  const mailOptions = {
    from, // sender address
    to: toList, // list of receivers
    subject, // 标题
    html,
  };

  return await transporter.sendMail(mailOptions);
}

module.exports = {
  send,
};
